﻿/**
 * ...
 * @author waneck
 */

package asc.events;

class ApplicationStatusTranslator
{
	public static function translate(infoObject: {code:String, level:String, details:Dynamic<String>} ):ApplicationStatus
	{
		return switch (infoObject.code)
		{
			case "Application.Script.Error":
				ApplicationScriptError(details.filename, details.lineno, details.linebuf);
			case "Application.Script.Warning":
				ApplicationScriptWarning(details.filename, details.lineno, details.linebuf);
			case "Application.Resource.LowMemory":
				ApplicationResourceLowMemory;
			default:
				null;
				//None;
		}
	}
}

class ApplicationStopTranslator
{
	public static function translate(infoObject: {code:String, level:String} ):ApplicationStop
	{
		return switch (infoObject.code)
		{
			case "Application.Shutdown":
				ApplicationShutdown;
			case "Application.GC":
				ApplicationGC;
		}
	}
}

enum ApplicationStatus
{

	ApplicationScriptError(filename:String, lineno:Int, linebuf:String);
	
	ApplicationScriptWarning(filename:String, lineno:Int, linebuf:String);
	
	ApplicationResourceLowMemory;
	
}

enum ApplicationStop
{
	ApplicationShutdown;
	
	ApplicationGC;
}

